import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/table';
import { RenderType } from '@pkg/setting';

export const columns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'userName',
    width: 150,
  },
  {
    title: '证件类型',
    dataIndex: 'userIdentityType',
    width: 80,
    dictData: [
      { label: '身份证', value: 1 },
      { label: '护照', value: 2 },
      { label: '回乡证(港澳台居民来往内地通行证)', value: 3 },
      { label: '台胞证', value: 4 },
      { label: '其他', value: 5 },
      { label: '军人证', value: 6 },
      { label: '外国居留身份证', value: 7 },
      { label: '港澳台居民居住证', value: 8 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '证件号',
    dataIndex: 'userIdentityNo',
    width: 160,
  },
  {
    title: '性别',
    dataIndex: 'userSex',
    width: 60,
    dictData: [
      { label: '女', value: 1 },
      { label: '男', value: 2 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '出生日期',
    dataIndex: 'birthDate',
    width: 100,
  },
  {
    title: '年龄',
    dataIndex: 'userAge',
    width: 60,
  },
  {
    title: '出发地',
    dataIndex: 'startPlace',
    width: 150,
  },
  {
    title: '创建日期',
    dataIndex: 'createTime',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '姓名',
    component: 'Input',
    colProps: { span: 5 },
  },
  {
    field: 'userIdentityNo',
    label: '证件号',
    component: 'Input',
    colProps: { span: 5 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '旅游记录Id',
    field: 'tourRecordId',
    component: 'Input',
    required: false,
    show: false,
  },
  {
    label: '姓名',
    field: 'userName',
    component: 'Input',
    required: true,
  },
  {
    field: 'userIdentityType',
    label: '证件类型',
    component: 'Select',
    required: true,
    defaultValue: 1,
    componentProps: ({ formModel }) => {
      return {
        options: [
          { label: '身份证', value: 1 },
          { label: '护照', value: 2 },
          { label: '回乡证(港澳台居民来往内地通行证)', value: 3 },
          { label: '台胞证', value: 4 },
          { label: '其他', value: 5 },
          { label: '军人证', value: 6 },
          { label: '外国居留身份证', value: 7 },
          { label: '港澳台居民居住证', value: 8 },
        ],
        onChange: identityType => {
          console.info('identityType', identityType);
          if (identityType == 1) {
            formModel.userSex = null;
            formModel.birthDate = null;
          }
        },
      };
    },
  },
  {
    label: '证件号',
    field: 'userIdentityNo',
    component: 'Input',
    required: true,
  },
  {
    label: '性别',
    field: 'userSex',
    required: true,
    component: 'Select',
    ifShow: ({ model }) => {
      return model.userIdentityType != 1;
    },
    componentProps: {
      options: [
        { label: '女', value: 1 },
        { label: '男', value: 2 },
      ],
    },
  },
  {
    label: '出生日期',
    field: 'birthDate',
    required: false,
    component: 'Input',
    ifShow: ({ model }) => {
      return model.userIdentityType != 1;
    },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    label: '出发地',
    field: 'startPlace',
    component: 'Input',
    required: false,
  },
];
